<?php
if(!defined('inside')) die('You do not have permission to execute this file directly.');

/**
* Database class file.
*
* @author Federico Ramirez <fedekiller@gmail.com>
* @link http://code.google.com/p/akaikiwi/
* @copyright Copyright &copy; 2008-2011 Federico Ramirez
* @license http://www.opensource.org/licenses/mit-license.php MIT Licence
*/

/*
* Initializes RedBean
*/
class Database {
	function __construct($dynamic = FALSE) {
		$config = AkaiKiwi::loadLib('Config');
		require_once 'akaikiwi/libs/vendor/redbean/rb.php';
		$str = $config->get_item('dbRBConnection');
		$str = explode('-', $str);
		$conn = $str[0];
		if(strpos($conn, 'sqlite') !== FALSE) {
			R::setup($conn);
		} else {
			R::setup($conn, $str[1], $str[2]);
		}
		if(!$dynamic) {
			R::freeze();
		}
	}
}
